﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using RPGProject.GameWorld;
using RPGProject.GameWorld.GameObjects;
using RPGProject.IOBuffers;
using RPGProject.Data_Structures;
using RPGProject.LoopSystem;
using System.Threading;
// begin namespace
namespace RPGProject
{

    // begin class program
    class Program
    {
        // begin main
        static void Main(string[] args)
        {
            // loads map
            World test = null;
            try
            {
                World.Load(Constants.GetInstance().GetString("StartingMap"), out test, 3, 5);
            }
            catch (Exception e)
            {
                Console.WriteLine("map.txt failed to load.  Please recreate file.");
                Console.ReadKey();
                return;
            }
            
            // initializes various stats and players

            Constants c = Constants.GetInstance();
            test["actionPoint"] = c["Player.ActionPoints"];
            test.AddStat("actionPoint", new StatOutputBuffer.Stat("Action Points", 0, 0, 20, 2));
            test["actionPoint"] = c["Player.ActionPoints"];
            test.AddStat("turn", new StatOutputBuffer.Stat("Turn #", 1, 0, 20, 0));
            test.AddStat("enemycount", new StatOutputBuffer.Stat("Enemy Count", 1, 21, 20, 0));
            test.Init();
            Player player = (Player)test["player"];
            player.AddUpdate(test.GetStatUpdate());
            test.AddStat("hp", new StatOutputBuffer.Stat("HP", 2, 0, 20, 0));
            test.AddStat("name", new StatOutputBuffer.Stat("Player Name", 0, 21, 20, 0));
            player["hp"] = Constants.GetInstance()["Player.MaxHP"];
            player["name"] = "Mirate";

            LoopManager looper = test.GetLoopManager();
            looper.Flush();
            while (looper.LoopOnce())
            {
                Thread.Sleep(looper.CurrentDelay);
            }

        }
    }
    // end class program
}
// end namespace
